package minh.app.mbook;



import android.app.Activity;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import androidhive.dashboard.R;

public class MBook extends Activity {	
	
	int count = 0;
	static boolean active = false;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFormat(PixelFormat.RGBA_8888);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);
        setContentView(R.layout.main);
        final TestLayout page = (TestLayout) findViewById(R.id.mainpage);
        final Handler mHandler  = new Handler();
        this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        final LinearLayout skip = (LinearLayout) findViewById(R.id.LinLayskip);
        final Intent login = new Intent(this, LoginActivity.class);
        
        skip.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) 
			{
				startActivity(login);
				active = true;
				count = 2;
			}
		});
        
        Runnable mUpdateTimeTask = new Runnable() 
    	{
    	    public void run() 
    	    {
    	        // Do some stuff that you want to do here
    	    	if(count <2)
    	    	{
    	    		page.next();
        	    	count++;
        	    // You could do this call if you wanted it to be periodic:
        	        mHandler.postDelayed(this, 8000);
    	    	}
    	    	else
    	    	{
    	    		if(active == false)
    	    		{
    	    		   startActivity(login);
    	    		}
    	    	}
    	    	

    	        }
    	    };
        
        
    	 mHandler.postDelayed(mUpdateTimeTask, 6000);
        
//        View pre = findViewById(R.id.btn_pre);
//        pre.setOnClickListener(new OnClickListener() {
//			
//			@Override
//			public void onClick(View v) 
//			{
//				page.pre();
//				
//			}
//		});
//        View next = findViewById(R.id.btn_next);
//        next.setOnClickListener(new OnClickListener() {
//			
//			@Override
//			public void onClick(View v) 
//			{
//				page.next();
//				
//			}
//		});
	}   
    
	
	
	
	    
    @Override
    protected void onPause() {
    	super.onPause();
    	onStop();
    }
   
    

}